<!--
 * @Description: 资源选择页面
 * @Author: JiangMing
 * @Date: 2021-09-8 15:22:00
 * @LastEditors: JiangMing
 * @LastEditTime: 2021-09-8 15:22:00
-->
<template>
  <view class="wrapper">
    <ContentResource
      v-if="pageType == 'resource'"
      :query="current"
      @back="classBack"
      @submit="resourceSubmit"
    />
    <ContentClass v-else @classClick="classClick" />
  </view>
</template>

<script>
import ContentClass from './components/content-class.vue';
import ContentResource from './components/content-resource.vue';

export default {
  components: {
    ContentClass,
    ContentResource
  },
  data() {
    return {
      pageType: 'class',
      current: {}
    }
  },
  onLoad() {
    // #ifdef APP-NVUE
    this.eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
    // #endif
    // #ifndef APP-NVUE
    this.eventChannel = this.getOpenerEventChannel();
    // #endif
  },
  methods: {
    classClick(row) {
      this.current = row;
      this.pageType = 'resource';
    },
    classBack() {
      this.pageType == 'class'
    },
    resourceSubmit(data) {
      console.log(data)
      this.eventChannel.emit('resourceChange', data);
      uni.navigateBack();
    }
  }
}
</script>

<style lang="scss" scoped>
.wrapper {

}
</style>